using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

namespace SynoManager
{
    public static class AcceptAllCertificatesPolicy
    {
        public static void Install()
        {
            ServicePointManager.ServerCertificateValidationCallback = 
                delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
                    {
                        //TODO: Check if we have a valid certificate
                        /*
                         * I just return true now, because the device sends an invalid certificate by default
                         * It would be nice if we had some way to check if the certificate is valid, because now the server
                         * can be spoofed.
                         */
                        return true; 
                    };
        }
    }
}